﻿@model ProductReviewOverviewModel
@using System.Globalization
@{
    int ratingPercent = 0;
    if (Model.TotalReviews != 0)
    {
        ratingPercent = ((Model.RatingSum * 100) / Model.TotalReviews) / 5;
    }
}
<div class="product-reviews-overview d-inline-flex align-items-center flex-wrap" @if (Model.TotalReviews > 0) { <text> itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" </text> }>
    <div class="product-review-box d-inline-block order-1">
        @{ 
            decimal ratingValue = 0;
            if (Model.TotalReviews != 0)
            {
                ratingValue = Convert.ToDecimal(((Model.RatingSum * (double)100) / Model.TotalReviews) / (double)100);
            }
        }
            <div class="rating">
                <b-form-rating id="rating-inline-overview-@Model.ProductId" class="p-0" variant="warning" no-border size="sm" show-value precision="2" readonly inline value="@(ratingValue)"></b-form-rating>
                @if (Model.TotalReviews > 0)
                {
                    <div class="product-review-links order-3">
                        <b-button variant="outline-info" size="sm" class="review-scroll-button" @@click="active = true" href="#review-tab___BV_tab_button__">
                            @Model.TotalReviews
                            @T("Reviews.Overview.Reviews")
                        </b-button>
                    </div>
                    @* microdata info*@
                    decimal ratingValuee = ratingPercent / (decimal)20;
                    <span itemprop="reviewCount" style="display: none;">(@ratingValuee.ToString("0.0", new CultureInfo("en-US")))</span>
                }
                else
                {
                    <div class="product-no-reviews order-3">
                        <b-button variant="outline-info" size="sm" href="@Url.RouteUrl("ProductReviews", new { productId = Model.ProductId })">
                                @T("Reviews.Overview.First")
                        </b-button>
                    </div>
                }
            </div>
    </div>
</div>
